In [19]:
import os
import matplotlib.pyplot as plt
import pandas as pd
import swat # SAS Viya Python interface
%matplotlib inline
In [2]:
DATA_URL = 'https://ti.arc.nasa.gov/m/project/prognostic-repository/Challenge_Data.zip'
DATA_DIR = '.'
train_tsv = os.path.join(DATA_DIR, 'train.txt')
test_tsv = os.path.join(DATA_DIR, 'test.txt')
if not os.path.isfile(train_tsv) or not os.path.isfile(test_tsv):
import zipfile
from six.moves import urllib
try:
filename, headers = urllib.request.urlretrieve(DATA_URL)
with zipfile.ZipFile(filename, 'r') as data_zip:
data_zip.extract('train.txt', DATA_DIR)
data_zip.extract('test.txt', DATA_DIR)
finally:
urllib.request.urlcleanup()
Read training data into a DataFrame.
In [3]:
# Create list of x1-x24
x = ['x%s' % i for i in range(1, 25)]
In [4]:
df = pd.read_table(train_tsv, delim_whitespace=True, names=['engine', 'cycle'] + x)
df.head()
Out[4]:
engine
cycle
x1
x2
x3
x4
x5
x6
x7
x8
...
x15
x16
x17
x18
x19
x20
x21
x22
x23
x24
0
1
1
10.0047
0.2501
20.0
489.05
604.13
1499.45
1309.95
10.52
...
372.15
2388.13
8120.83
8.6216
0.03
368
2319
100.0
28.58
17.1735
1
1
2
0.0015
0.0003
100.0
518.67
642.13
1584.55
1403.96
14.62
...
521.81
2388.15
8132.87
8.3907
0.03
391
2388
100.0
38.99
23.3619
2
1
3
34.9986
0.8401
60.0
449.44
555.42
1368.17
1122.49
5.48
...
183.26
2387.95
8063.84
9.3557
0.02
334
2223
100.0
14.83
8.8555
3
1
4
20.0031
0.7005
0.0
491.19
607.03
1488.44
1249.18
9.35
...
314.84
2388.07
8052.30
9.2231
0.02
364
2324
100.0
24.42
14.7832
4
1
5
42.0041
0.8405
40.0
445.00
549.52
1354.48
1124.32
3.91
...
130.44
2387.89
8083.67
9.2986
0.02
330
2212
100.0
10.99
6.4025
5 rows × 26 columns
Create training data with 30 random engines
In [5]:
train = df[df['engine'].isin([7, 28, 32, 38, 40, 51, 65, 84, 90, 95, 99, 107,
120, 124, 135, 137, 138, 148, 151, 160, 166, 178,
182, 188, 197, 199, 200, 207, 210, 211])]
# Keep first 50 observations per engine to train SVDD
train = train[train['cycle'] <= 50]
train['index'] = train.index
train.tail()
Out[5]:
engine
cycle
x1
x2
x3
x4
x5
x6
x7
x8
...
x16
x17
x18
x19
x20
x21
x22
x23
x24
index
44296
211
46
0.0019
0.0015
100.0
518.67
642.32
1585.44
1403.71
14.62
...
2388.05
8136.64
8.4008
0.03
392
2388
100.00
38.94
23.4167
44296
44297
211
47
25.0045
0.6204
80.0
462.54
536.09
1261.04
1043.58
7.05
...
2028.23
7877.28
10.8351
0.02
306
1915
84.93
14.33
8.5657
44297
44298
211
48
25.0009
0.6200
80.0
462.54
536.70
1258.17
1045.69
7.05
...
2028.16
7868.87
10.8982
0.02
307
1915
84.93
14.15
8.5617
44298
44299
211
49
34.9992
0.8400
60.0
449.44
555.55
1357.05
1124.54
5.48
...
2387.98
8060.58
9.3039
0.02
333
2223
100.00
15.05
9.0326
44299
44300
211
50
34.9985
0.8401
60.0
449.44
555.79
1361.79
1115.64
5.48
...
2388.03
8065.22
9.2908
0.02
334
2223
100.00
14.88
9.0062
44300
5 rows × 27 columns
Read test data into a DataFrame.
In [6]:
df = pd.read_table('test.txt', delim_whitespace=True, names=['engine', 'cycle'] + x)
# create a scoring data set with 9 random engines from the test data set
df['index'] = df.index
score = df[df['engine'].isin([1, 8, 22, 53, 63, 86, 102, 158, 170, 202])]
score.tail()
Out[6]:
engine
cycle
x1
x2
x3
x4
x5
x6
x7
x8
...
x16
x17
x18
x19
x20
x21
x22
x23
x24
index
27762
202
220
25.0016
0.6200
80.0
462.54
536.90
1269.39
1060.73
7.05
...
2028.26
7871.43
10.9634
0.02
310
1915
84.93
14.24
8.4615
27762
27763
202
221
0.0028
0.0000
100.0
518.67
643.27
1598.17
1421.01
14.62
...
2388.21
8138.45
8.4976
0.03
395
2388
100.00
38.68
23.1797
27763
27764
202
222
34.9982
0.8400
60.0
449.44
555.96
1377.66
1141.88
5.48
...
2388.13
8069.36
9.3483
0.02
335
2223
100.00
14.69
8.9512
27764
27765
202
223
25.0020
0.6208
80.0
462.54
537.21
1267.70
1063.08
7.05
...
2028.27
7878.83
11.0023
0.02
309
1915
84.93
14.22
8.4076
27765
27766
202
224
24.9998
0.6200
80.0
462.54
537.08
1270.70
1064.61
7.05
...
2028.28
7884.13
10.9798
0.02
309
1915
84.93
14.13
8.4066
27766
5 rows × 27 columns
In [8]:
s = swat.CAS('localhost', 5570)
In [9]:
train_tbl = s.upload_frame(train, casout=dict(name='train', replace=True))
score_tbl = s.upload_frame(score, casout=dict(name='score', replace=True))
NOTE: Cloud Analytic Services made the uploaded file available as table TRAIN in caslib CASUSER(kesmit).
NOTE: The table TRAIN has been created in caslib CASUSER(kesmit) from binary data uploaded to Cloud Analytic Services.
NOTE: Cloud Analytic Services made the uploaded file available as table SCORE in caslib CASUSER(kesmit).
NOTE: The table SCORE has been created in caslib CASUSER(kesmit) from binary data uploaded to Cloud Analytic Services.
Check details of loaded tables.
In [10]:
s.tableinfo()
Out[10]:
§ TableInfo
Name
Rows
Columns
IndexedColumns
Encoding
CreateTimeFormatted
ModTimeFormatted
AccessTimeFormatted
JavaCharSet
CreateTime
ModTime
AccessTime
Global
Repeated
View
SourceName
SourceCaslib
Compressed
Creator
Modifier
0
TRAIN
1500
27
0
utf-8
04Oct2017:18:54:20
04Oct2017:18:54:20
04Oct2017:18:54:20
UTF8
1.822762e+09
1.822762e+09
1.822762e+09
0
0
0
0
kesmit
1
SCORE
1502
27
0
utf-8
04Oct2017:18:54:21
04Oct2017:18:54:21
04Oct2017:18:54:21
UTF8
1.822762e+09
1.822762e+09
1.822762e+09
0
0
0
0
kesmit
elapsed 0.00237s · user 0.003s · mem 0.716MB
In [11]:
s.loadactionset('svdd')
NOTE: Added action set 'svdd'.
Out[11]:
§ actionset
svdd
elapsed 0.00209s · user 0.002s · mem 0.237MB
In [12]:
# Run svdd.svddTrain action set on training data
ysvdd_state = s.CASTable('ysvddstate', replace=True)
state_s = s.CASTable('state_s', replace=True)
train_tbl.svdd.svddtrain(gauss=11,
solver='actset',
inputs=x,
savestate=ysvdd_state,
output=dict(casout=state_s),
id='index')
NOTE: Beginning data reading...
NOTE: Data reading complete.
NOTE: Beginning SVDD optimization...
NOTE: SVDD optimization complete.
NOTE: Output generation complete.
NOTE: Beginning of support vector table generation...
NOTE: Support vector table generation complete.
NOTE: Beginning save state generation...
NOTE: Wrote 37669 bytes to the savestate file ysvddstate.
NOTE: Save state generation complete.
Out[12]:
§ ModelInfo
Model Information
RowId
Description
Value
nValue
0
OPTMETHOD
Optimization Method
Active set
NaN
1
KERTYPE
Kernel Type
RBF
NaN
2
BW
RBF Kernel Bandwidth
11
11.000000
3
RELSCALE
Bandwidth Relative Scale
0.089542561
0.089543
4
FRAC
Expected Outlier Fraction
1E-6
0.000001
5
OPTTOL
Optimization Tolerance
0.0001
0.000100
6
NINTVARS
Number of Interval Variables
24
24.000000
7
NNOMVARS
Number of Nominal Variables
0
0.000000
§ Nobs
Number of Observations
Type
N
0
Number of Observations Read
1500.0
1
Number of Observations Used
1500.0
§ OptSummary
Optimization Summary
RowId
Description
Value
nValue
0
NITERS
Number of Iterations
1
1.000000
1
OBJ
Objective Value
0.0301437585
0.030144
2
INFEA
Infeasibility
0.0000494674
0.000049
3
OPTSTATUS
Optimization Status
Optimal
NaN
4
DEGEN
Degenerate
False
0.000000
§ TrainingResults
Training Results
RowId
Description
Value
0
NSV
Number of Support Vectors
135.000000
1
NSVB
Number of Support Vectors on Boundary
135.000000
2
NDROBS
Number of Dropped Observations
0.000000
3
THRESH
Threshold R^2 Value
0.969932
4
C_R
Constant (C_r) Value
0.030144
5
RTIME
Run Time (Seconds)
0.076728
§ OutputCasTables
casLib
Name
Label
Rows
Columns
casTable
0
CASUSER(kesmit)
state_s
135
27
CASTable(u'state_s', caslib=u'CASUSER(kesmit)')
elapsed 0.207s · user 0.173s · sys 0.091s · mem 50.8MB
In [13]:
sv = state_s.to_frame()
sv
Out[13]:
Selected Rows from Table STATE_S
index
X1
X2
X3
X4
X5
X6
X7
X8
X9
...
X17
X18
X19
X20
X21
X22
X23
X24
_SVDDALPHA_
_SVDDOUTLIER_
0
1285.0
42.0068
0.8413
40.0
445.00
549.78
1359.17
1113.20
3.91
5.71
...
8087.68
9.3337
0.02
330.0
2212.0
100.00
10.76
6.3550
0.006056
0.0
1
1294.0
25.0021
0.6213
80.0
462.54
536.55
1254.33
1037.37
7.05
9.03
...
7869.70
10.8674
0.02
306.0
1915.0
84.93
14.22
8.5386
0.002464
0.0
2
1299.0
42.0020
0.8400
40.0
445.00
549.11
1341.54
1114.18
3.91
5.72
...
8089.02
9.3296
0.02
331.0
2212.0
100.00
10.60
6.3265
0.011382
0.0
3
1312.0
35.0037
0.8400
60.0
449.44
555.87
1356.61
1114.82
5.48
8.00
...
8066.95
9.3072
0.02
333.0
2223.0
100.00
14.80
8.9329
0.009289
0.0
4
1317.0
10.0002
0.2505
20.0
489.05
604.16
1495.14
1302.19
10.52
15.49
...
8132.86
8.6005
0.03
370.0
2319.0
100.00
28.68
17.1952
0.000666
0.0
5
5518.0
10.0047
0.2507
20.0
489.05
604.81
1503.70
1320.02
10.52
15.49
...
8130.53
8.6714
0.03
370.0
2319.0
100.00
28.67
17.2177
0.011125
0.0
6
5524.0
10.0068
0.2500
20.0
489.05
604.42
1503.76
1323.48
10.52
15.49
...
8126.49
8.6490
0.03
368.0
2319.0
100.00
28.44
17.1407
0.012131
0.0
7
5527.0
0.0027
0.0007
100.0
518.67
642.91
1585.05
1413.34
14.62
21.61
...
8117.66
8.4237
0.03
395.0
2388.0
100.00
38.91
23.1822
0.001383
0.0
8
6544.0
35.0028
0.8412
60.0
449.44
555.61
1370.41
1132.09
5.48
8.00
...
8065.85
9.3431
0.02
333.0
2223.0
100.00
14.88
8.8200
0.002926
0.0
9
7799.0
0.0025
0.0013
100.0
518.67
642.68
1580.83
1405.11
14.62
21.61
...
8122.67
8.4418
0.03
393.0
2388.0
100.00
38.81
23.3484
0.004536
0.0
10
7817.0
35.0027
0.8403
60.0
449.44
555.34
1354.19
1127.28
5.48
8.00
...
8055.34
9.3066
0.02
333.0
2223.0
100.00
15.01
8.9349
0.006855
0.0
11
7823.0
10.0018
0.2507
20.0
489.05
604.18
1501.26
1312.17
10.52
15.49
...
8113.77
8.6587
0.03
368.0
2319.0
100.00
28.42
17.1159
0.000654
0.0
12
7825.0
35.0011
0.8400
60.0
449.44
556.01
1361.05
1122.15
5.48
8.00
...
8051.78
9.3395
0.02
333.0
2223.0
100.00
14.98
8.8866
0.004063
0.0
13
8264.0
35.0076
0.8402
60.0
449.44
555.32
1372.32
1122.33
5.48
8.00
...
8071.48
9.3156
0.02
335.0
2223.0
100.00
14.82
8.8401
0.002389
0.0
14
8271.0
35.0034
0.8403
60.0
449.44
555.16
1352.47
1131.17
5.48
8.00
...
8069.63
9.3281
0.02
333.0
2223.0
100.00
14.62
8.9081
0.008155
0.0
15
10783.0
20.0066
0.7000
0.0
491.19
606.60
1483.72
1240.52
9.35
13.65
...
8063.96
9.1742
0.02
362.0
2324.0
100.00
24.54
14.8039
0.002665
0.0
16
10786.0
20.0011
0.7000
0.0
491.19
606.49
1471.23
1244.47
9.35
13.65
...
8056.10
9.1967
0.02
364.0
2324.0
100.00
24.61
14.6523
0.006305
0.0
17
10799.0
0.0021
0.0012
100.0
518.67
642.72
1594.19
1389.79
14.62
21.60
...
8132.71
8.4003
0.03
392.0
2388.0
100.00
39.00
23.3553
0.018188
0.0
18
10808.0
10.0035
0.2502
20.0
489.05
604.02
1484.73
1304.16
10.52
15.49
...
8131.00
8.6404
0.03
368.0
2319.0
100.00
28.47
17.1854
0.016680
0.0
19
13645.0
42.0006
0.8418
40.0
445.00
550.22
1361.26
1127.72
3.91
5.71
...
8075.21
9.3746
0.02
331.0
2212.0
100.00
10.45
6.4058
0.000966
0.0
20
13666.0
0.0029
0.0000
100.0
518.67
642.79
1598.52
1414.95
14.62
21.61
...
8124.86
8.4640
0.03
393.0
2388.0
100.00
38.74
23.2150
0.011858
0.0
21
13675.0
20.0078
0.7000
0.0
491.19
607.79
1491.57
1259.33
9.35
13.66
...
8060.86
9.2345
0.02
365.0
2324.0
100.00
24.58
14.6270
0.014638
0.0
22
13683.0
25.0037
0.6214
80.0
462.54
536.79
1267.51
1060.56
7.05
9.02
...
7862.81
10.9034
0.02
307.0
1915.0
84.93
14.23
8.6206
0.019906
0.0
23
17516.0
25.0050
0.6200
80.0
462.54
536.71
1263.32
1046.01
7.05
9.02
...
7872.69
10.8939
0.02
306.0
1915.0
84.93
14.35
8.6926
0.002602
0.0
24
17519.0
20.0045
0.7000
0.0
491.19
607.55
1484.51
1253.34
9.35
13.65
...
8054.21
9.1967
0.02
365.0
2324.0
100.00
24.57
14.7950
0.002014
0.0
25
17529.0
20.0031
0.7010
0.0
491.19
607.54
1480.69
1247.78
9.35
13.66
...
8047.76
9.2371
0.02
363.0
2324.0
100.00
24.46
14.7753
0.001331
0.0
26
17531.0
42.0019
0.8400
40.0
445.00
548.95
1345.59
1115.81
3.91
5.71
...
8073.09
9.3708
0.02
329.0
2212.0
100.00
10.37
6.3725
0.009717
0.0
27
18704.0
10.0046
0.2500
20.0
489.05
604.73
1494.77
1295.69
10.52
15.49
...
8121.32
8.6238
0.03
369.0
2319.0
100.00
28.67
17.1588
0.006908
0.0
28
18717.0
9.9997
0.2515
20.0
489.05
604.20
1500.15
1293.17
10.52
15.49
...
8125.86
8.6452
0.03
367.0
2319.0
100.00
28.63
17.2109
0.001174
0.0
29
18726.0
0.0004
0.0007
100.0
518.67
642.44
1576.54
1408.26
14.62
21.61
...
8123.02
8.4546
0.03
392.0
2388.0
100.00
38.97
23.3436
0.012968
0.0
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
105
39479.0
0.0027
0.0000
100.0
518.67
641.80
1586.14
1400.86
14.62
21.61
...
8155.08
8.4395
0.03
392.0
2388.0
100.00
39.14
23.4434
0.010255
0.0
106
39490.0
20.0063
0.7000
0.0
491.19
607.12
1485.11
1238.49
9.35
13.65
...
8068.58
9.1763
0.02
364.0
2324.0
100.00
24.69
14.8385
0.003269
0.0
107
41498.0
25.0060
0.6216
80.0
462.54
537.07
1261.96
1037.84
7.05
9.02
...
7883.99
10.8780
0.02
305.0
1915.0
84.93
14.47
8.6213
0.001740
0.0
108
41504.0
42.0055
0.8408
40.0
445.00
549.59
1357.94
1127.82
3.91
5.72
...
8098.62
9.3584
0.02
329.0
2212.0
100.00
10.66
6.3463
0.004808
0.0
109
41505.0
42.0033
0.8401
40.0
445.00
549.14
1357.28
1128.36
3.91
5.72
...
8096.40
9.3662
0.02
331.0
2212.0
100.00
10.71
6.3247
0.006098
0.0
110
41513.0
24.9982
0.6200
80.0
462.54
536.39
1255.83
1041.14
7.05
9.02
...
7876.51
10.8766
0.02
308.0
1915.0
84.93
14.34
8.5946
0.002180
0.0
111
41519.0
10.0032
0.2510
20.0
489.05
604.72
1493.06
1311.05
10.52
15.49
...
8141.32
8.6594
0.03
369.0
2319.0
100.00
28.57
17.1261
0.006390
0.0
112
41521.0
34.9987
0.8400
60.0
449.44
555.35
1364.35
1126.94
5.48
8.00
...
8082.15
9.3243
0.02
333.0
2223.0
100.00
14.90
8.9119
0.016845
0.0
113
41530.0
0.0027
0.0000
100.0
518.67
642.68
1589.87
1408.62
14.62
21.61
...
8149.18
8.4317
0.03
393.0
2388.0
100.00
38.86
23.3584
0.013258
0.0
114
41535.0
20.0021
0.7000
0.0
491.19
606.81
1489.99
1252.05
9.35
13.66
...
8064.97
9.1924
0.02
364.0
2324.0
100.00
24.52
14.7819
0.017613
0.0
115
41543.0
25.0037
0.6216
80.0
462.54
536.60
1254.89
1046.09
7.05
9.03
...
7885.03
10.8929
0.02
308.0
1915.0
84.93
14.40
8.6733
0.008280
0.0
116
41793.0
10.0012
0.2500
20.0
489.05
604.56
1504.99
1303.39
10.52
15.49
...
8122.09
8.6554
0.03
370.0
2319.0
100.00
28.52
17.1730
0.001880
0.0
117
41804.0
34.9986
0.8400
60.0
449.44
555.83
1375.37
1132.08
5.48
8.00
...
8060.12
9.3300
0.02
333.0
2223.0
100.00
14.88
8.9641
0.002310
0.0
118
41825.0
35.0046
0.8418
60.0
449.44
555.93
1362.66
1132.96
5.48
8.00
...
8065.45
9.3222
0.02
334.0
2223.0
100.00
14.89
8.8823
0.006423
0.0
119
41830.0
42.0005
0.8400
40.0
445.00
550.00
1344.59
1117.26
3.91
5.71
...
8074.73
9.3565
0.02
331.0
2212.0
100.00
10.45
6.3914
0.004932
0.0
120
41837.0
19.9991
0.7000
0.0
491.19
607.84
1476.38
1261.29
9.35
13.65
...
8056.42
9.2398
0.02
364.0
2324.0
100.00
24.64
14.6685
0.011368
0.0
121
41983.0
9.9982
0.2506
20.0
489.05
604.19
1499.72
1294.98
10.52
15.49
...
8133.45
8.6344
0.03
368.0
2319.0
100.00
28.62
17.1976
0.010751
0.0
122
41985.0
41.9989
0.8414
40.0
445.00
548.82
1345.77
1115.30
3.91
5.72
...
8097.22
9.3565
0.02
329.0
2212.0
100.00
10.90
6.3831
0.013570
0.0
123
41998.0
20.0074
0.7000
0.0
491.19
606.59
1480.23
1235.86
9.35
13.65
...
8057.44
9.1375
0.02
364.0
2324.0
100.00
24.60
14.7434
0.006796
0.0
124
42003.0
0.0024
0.0018
100.0
518.67
642.18
1583.37
1392.37
14.62
21.60
...
8128.38
8.3978
0.03
393.0
2388.0
100.00
39.20
23.3618
0.004621
0.0
125
42005.0
0.0006
0.0001
100.0
518.67
642.43
1581.42
1391.50
14.62
21.61
...
8140.75
8.4112
0.03
392.0
2388.0
100.00
39.12
23.4833
0.000443
0.0
126
43295.0
19.9995
0.7018
0.0
491.19
607.75
1486.81
1257.66
9.35
13.66
...
8056.03
9.2597
0.02
365.0
2324.0
100.00
24.44
14.6475
0.001213
0.0
127
43296.0
10.0030
0.2516
20.0
489.05
604.12
1510.74
1311.54
10.52
15.49
...
8123.00
8.6470
0.03
369.0
2319.0
100.00
28.51
17.1585
0.000300
0.0
128
43299.0
25.0006
0.6211
80.0
462.54
537.28
1248.77
1051.94
7.05
9.03
...
7871.33
10.8660
0.02
308.0
1915.0
84.93
14.21
8.6010
0.008971
0.0
129
43334.0
42.0022
0.8400
40.0
445.00
549.68
1358.55
1126.54
3.91
5.71
...
8076.27
9.3713
0.02
329.0
2212.0
100.00
10.47
6.3701
0.000103
0.0
130
44033.0
10.0071
0.2500
20.0
489.05
604.59
1496.44
1309.44
10.52
15.50
...
8125.06
8.5922
0.03
368.0
2319.0
100.00
28.50
17.2225
0.000856
0.0
131
44042.0
9.9989
0.2505
20.0
489.05
604.77
1507.39
1303.37
10.52
15.49
...
8116.53
8.6360
0.03
370.0
2319.0
100.00
28.68
17.0965
0.004780
0.0
132
44255.0
0.0011
0.0000
100.0
518.67
641.95
1579.77
1397.90
14.62
21.61
...
8135.56
8.3642
0.03
391.0
2388.0
100.00
38.94
23.3584
0.002849
0.0
133
44271.0
35.0076
0.8400
60.0
449.44
555.34
1364.51
1114.25
5.48
8.00
...
8062.73
9.3049
0.02
334.0
2223.0
100.00
14.95
8.8803
0.017371
0.0
134
44276.0
42.0027
0.8400
40.0
445.00
549.38
1338.13
1120.71
3.91
5.71
...
8082.58
9.3358
0.02
329.0
2212.0
100.00
10.77
6.3720
0.012707
0.0
135 rows × 27 columns
In [14]:
# Load astore action set
s.loadactionset('astore')
NOTE: Added action set 'astore'.
Out[14]:
§ actionset
astore
elapsed 0.0011s · user 0.000999s · mem 0.266MB
In [15]:
# Score resulting SVDD astore (ysvddstate) against the scoring data (score) and output results (svddscored)
svdd_scored = s.CASTable('svddscored', replace=True)
score_tbl.astore.score(rstore=ysvdd_state, out=svdd_scored)
Out[15]:
§ Timing
Task Timing
Task
Seconds
Percent
0
Loading the Store
0.000093
0.000349
1
Creating the State
0.037361
0.140184
2
Scoring
0.229059
0.859457
3
Total
0.266516
1.000000
elapsed 0.274s · user 0.116s · sys 0.043s · mem 37.4MB
In [16]:
# Create local dataframe of scored data to plot using Matplotlib
output = svdd_scored.to_frame()
output.head()
Out[16]:
Selected Rows from Table SVDDSCORED
index
_SVDDDISTANCE_
_SVDDSCORE_
0
0.0
0.953083
-1.0
1
1.0
1.008100
1.0
2
2.0
0.957298
-1.0
3
3.0
0.966277
-1.0
4
4.0
0.960607
-1.0
In [17]:
# Add SVDD scored values to original score DataFrame for plotting purposes
df = score.merge(output, how='left')
df.head()
Out[17]:
engine
cycle
x1
x2
x3
x4
x5
x6
x7
x8
...
x18
x19
x20
x21
x22
x23
x24
index
_SVDDDISTANCE_
_SVDDSCORE_
0
1
1
0.0016
0.0002
100.0
518.67
642.88
1587.21
1412.44
14.62
...
8.4363
0.03
393
2388
100.00
38.97
23.3029
0
0.953083
-1.0
1
1
2
24.9993
0.6215
80.0
462.54
536.45
1262.64
1055.44
7.05
...
10.8935
0.02
308
1915
84.93
14.29
8.6686
1
1.008100
1.0
2
1
3
0.0004
0.0000
100.0
518.67
642.65
1589.75
1409.54
14.62
...
8.4620
0.03
393
2388
100.00
38.91
23.2693
2
0.957298
-1.0
3
1
4
10.0034
0.2500
20.0
489.05
604.44
1499.93
1315.34
10.52
...
8.6815
0.03
369
2319
100.00
28.60
17.0930
3
0.966277
-1.0
4
1
5
0.0024
0.0011
100.0
518.67
642.74
1585.47
1408.12
14.62
...
8.4617
0.03
392
2388
100.00
38.82
23.3124
4
0.960607
-1.0
5 rows × 29 columns
In [27]:
df = df.loc[df['engine'] < 150]
for index, group in df.groupby('engine'):
group.plot(x='cycle', y='_SVDDDISTANCE_', title=index, label='engine', figsize=(15, 4))
plt.show()
In [22]:
# Download SVDD astore for use in SAS Event Stream Processing (ESP)
results = s.astore.download(rstore=ysvdd_state)
In [23]:
# Check details of loaded data
s.tableinfo()
Out[23]:
§ TableInfo
Name
Rows
Columns
IndexedColumns
Encoding
CreateTimeFormatted
ModTimeFormatted
AccessTimeFormatted
JavaCharSet
CreateTime
ModTime
AccessTime
Global
Repeated
View
SourceName
SourceCaslib
Compressed
Creator
Modifier
0
TRAIN
1500
27
0
utf-8
04Oct2017:18:54:20
04Oct2017:18:54:20
04Oct2017:18:54:26
UTF8
1.822762e+09
1.822762e+09
1.822762e+09
0
0
0
0
kesmit
1
SCORE
1502
27
0
utf-8
04Oct2017:18:54:21
04Oct2017:18:54:21
04Oct2017:18:54:30
UTF8
1.822762e+09
1.822762e+09
1.822762e+09
0
0
0
0
kesmit
2
STATE_S
135
27
0
utf-8
04Oct2017:18:54:27
04Oct2017:18:54:27
04Oct2017:18:54:28
UTF8
1.822762e+09
1.822762e+09
1.822762e+09
0
0
0
0
kesmit
3
YSVDDSTATE
1
2
0
utf-8
04Oct2017:18:54:27
04Oct2017:18:54:27
04Oct2017:18:56:37
UTF8
1.822762e+09
1.822762e+09
1.822763e+09
0
0
0
0
kesmit
4
SVDDSCORED
1502
3
0
utf-8
04Oct2017:18:54:30
04Oct2017:18:54:30
04Oct2017:18:54:32
UTF8
1.822762e+09
1.822762e+09
1.822762e+09
0
0
0
0
kesmit
elapsed 0.0022s · user 0.002s · mem 0.721MB
Content source: sassoftware/sas-viya-programming
Similar notebooks: